package zhupf.test.designPattern.composite;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class University extends OrganizationComponsite {

    private List<OrganizationComponsite> list = new ArrayList<>();

    public University(String name){
        this.setName(name);
    }

    public University() {

    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public void add(OrganizationComponsite organizationComponsite) {
        list.add(organizationComponsite);
    }

    @Override
    public void print() {
        System.out.println(this.getName());
        list.forEach(i-> i.print());
    }
}
